#include "ktv/gui/keyboard/inputfield.h"

#include <QtGui>
#include "ktv/model/resource/resource.h"

InputField::InputField(QGraphicsItem *parent)
    : QGraphicsObject(parent)
{
    width = 250;
    height = 40;
    background = Resource::getInstance()->input_field_background;
    text = "";
}

QRectF InputField::boundingRect() const
{
    return QRectF(-width/2.0, -height/2.0, width, height);
}

void InputField::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);
    painter->drawPixmap(-width/2.0, -height/2.0, width, height, *background);
    painter->setFont(QFont("Times", 60, QFont::Bold));
    painter->drawText(-100, 0, text);
}

void InputField::setText(QString t)
{
    text = t;
    update();
}
